﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Collections;
using System.Data;
using System.Reflection;

namespace ESM.Objetos
{
    public static class Application_ESM
    {
        public static DataTable ConvertToDataTable(IEnumerable ien)
        {
            DataTable dt = new DataTable();
            foreach (object obj in ien)
            {
                Type t = obj.GetType();
                PropertyInfo[] pis = t.GetProperties();
                if (dt.Columns.Count == 0)
                {
                    foreach (PropertyInfo pi in pis)
                    {
                        dt.Columns.Add(pi.Name, pi.PropertyType);
                    }
                }
                DataRow dr = dt.NewRow();
                foreach (PropertyInfo pi in pis)
                {
                    object value = pi.GetValue(obj, null);
                    dr[pi.Name] = value;
                }
                dt.Rows.Add(dr);
            }
            return dt;
        }
    }
    public class CLecturaContextoEE
    {
        #region Propiedades Privadas y Publicas

        //ESM.Model.ESMBDDataContext _db = new Model.ESMBDDataContext();

        CConexion _cn = new CConexion();
        ESMOffline.ESMDataSet _db = new ESMOffline.ESMDataSet();


        #region Seccion Informacion

        private int _num_sedes;

        public int Numero_Sedes
        {
            get { return _num_sedes; }
            set { _num_sedes = value; }
        }

        #endregion

        #region Seccion 1
        private bool _f11;

        public bool F11
        {
            get { return _f11; }
            set { _f11 = value; }
        }

        private bool _f12;

        public bool F12
        {
            get { return _f12; }
            set { _f12 = value; }
        }

        private bool _f13;

        public bool F13
        {
            get { return _f13; }
            set { _f13 = value; }
        }

        private bool _f14;

        public bool F14
        {
            get { return _f14; }
            set { _f14 = value; }
        }

        private bool _f15;

        public bool F15
        {
            get { return _f15; }
            set { _f15 = value; }
        }

        private int _d;

        public int D
        {
            get { return _d; }
            set { _d = value; }
        }

        private bool __1_2_urbana;

        public bool _1_2_Urbana
        {
            get { return __1_2_urbana; }
            set { __1_2_urbana = value; }
        }

        private bool __1_2_rural;

        public bool _1_2_Rural
        {
            get { return __1_2_rural; }
            set { __1_2_rural = value; }
        }

        private bool __1_2_c1;

        public bool _1_2_c1
        {
            get { return __1_2_c1; }
            set { __1_2_c1 = value; }
        }

        private bool __1_2_c2;

        public bool _1_2_c2
        {
            get { return __1_2_c2; }
            set { __1_2_c2 = value; }
        }

        private bool __1_2_c3;

        public bool _1_2_c3
        {
            get { return __1_2_c3; }
            set { __1_2_c3 = value; }
        }

        private bool __1_2_c4;

        public bool _1_2_c4
        {
            get { return __1_2_c4; }
            set { __1_2_c4 = value; }
        }

        private int _numerosedes;

        public int Sedes
        {
            get { return _numerosedes; }
            set { _numerosedes = value; }
        }

        private bool __c_1;

        public bool C_1
        {
            get { return __c_1; }
            set { __c_1 = value; }
        }

        private bool __c_2;

        public bool C_2
        {
            get { return __c_2; }
            set { __c_2 = value; }
        }
        private bool __c_3;

        public bool C_3
        {
            get { return __c_3; }
            set { __c_3 = value; }
        }
        private bool __c_4;

        public bool C_4
        {
            get { return __c_4; }
            set { __c_4 = value; }
        }
        private bool __c_5;

        public bool C_5
        {
            get { return __c_5; }
            set { __c_5 = value; }
        }
        #endregion

        #region Seccion 2
        private int __2_1;

        public int _2_1_
        {
            get { return __2_1; }
            set { __2_1 = value; }
        }

        private int __2_2_e1;

        public int _2_2_E1_
        {
            get { return __2_2_e1; }
            set { __2_2_e1 = value; }
        }

        private int __2_2_e2;

        public int _2_2_E2_
        {
            get { return __2_2_e2; }
            set { __2_2_e2 = value; }
        }

        private int __2_2_e3;

        public int _2_2_E3_
        {
            get { return __2_2_e3; }
            set { __2_2_e3 = value; }
        }

        private int __2_2_e4;

        public int _2_2_E4_
        {
            get { return __2_2_e4; }
            set { __2_2_e4 = value; }
        }

        private int __2_2_e5;

        public int _2_2_E5_
        {
            get { return __2_2_e5; }
            set { __2_2_e5 = value; }
        }

        private int __2_2_e6;

        public int _2_2_E6_
        {
            get { return __2_2_e6; }
            set { __2_2_e6 = value; }
        }

        private int __2_3_s1;

        public int _2_3_S1_
        {
            get { return __2_3_s1; }
            set { __2_3_s1 = value; }
        }

        private int __2_3_s2;

        public int _2_3_S2_
        {
            get { return __2_3_s2; }
            set { __2_3_s2 = value; }
        }

        private int __2_3_s3;

        public int _2_3_S3_
        {
            get { return __2_3_s3; }
            set { __2_3_s3 = value; }
        }

        private int __2_3_s4;

        public int _2_3_S4_
        {
            get { return __2_3_s4; }
            set { __2_3_s4 = value; }
        }

        private int __2_3_sNosabe;

        public int _2_3_SNosabe_
        {
            get { return __2_3_sNosabe; }
            set { __2_3_sNosabe = value; }
        }

        private int __2_3_sNoTiene;

        public int _2_3_SNoTiene_
        {
            get { return __2_3_sNoTiene; }
            set { __2_3_sNoTiene = value; }
        }

        private bool ___2_4_Si;

        public bool _2_4_Si
        {
            get { return ___2_4_Si; }
            set { ___2_4_Si = value; }
        }

        private bool ___2_4_No;

        public bool _2_4_No
        {
            get { return ___2_4_No; }
            set { ___2_4_No = value; }
        }

        private int __2_5_1;

        public int _2_5_1_
        {
            get { return __2_5_1; }
            set { __2_5_1 = value; }
        }

        private int __2_5_2;

        public int __2_5_2_
        {
            get { return __2_5_2; }
            set { __2_5_2 = value; }
        }

        private int __2_5_3_;

        public int _2_5_3_
        {
            get { return __2_5_3_; }
            set { __2_5_3_ = value; }
        }

        #endregion

        #region Seccion 3

        private string __3_1;

        public string _3_1_
        {
            get { return __3_1; }
            set { __3_1 = value; }
        }

        private string __3_2_;

        public string _3_2_
        {
            get { return __3_2_; }
            set { __3_2_ = value; }
        }

        private string __3_3_;

        public string _3_3
        {
            get { return __3_3_; }
            set { __3_3_ = value; }
        }

        private bool __3_4_Si;

        public bool _3_4_Si
        {
            get { return __3_4_Si; }
            set { __3_4_Si = value; }
        }

        private bool __3_4_No;

        public bool _3_4_No
        {
            get { return __3_4_No; }
            set { __3_4_No = value; }
        }
        private string __3_4_1;

        public string _3_4_1_
        {
            get { return __3_4_1; }
            set { __3_4_1 = value; }
        }

        private bool __3_5_Si;

        public bool _3_5_Si
        {
            get { return __3_5_Si; }
            set { __3_5_Si = value; }
        }

        private bool __3_5_No;

        public bool _3_5_No
        {
            get { return __3_5_No; }
            set { __3_5_No = value; }
        }

        private string __3_5_1;

        public string _3_5_1_
        {
            get { return __3_5_1; }
            set { __3_5_1 = value; }
        }

        private string __3_5_2;

        public string _3_5_2_
        {
            get { return __3_5_2; }
            set { __3_5_2 = value; }
        }

        private string __3_5_3;

        public string _3_5_3_
        {
            get { return __3_5_3; }
            set { __3_5_3 = value; }
        }

        private string __3_5_4;

        public string _3_5_4_
        {
            get { return __3_5_4; }
            set { __3_5_4 = value; }
        }

        private string __3_5_5;

        public string _3_5_5_
        {
            get { return __3_5_5; }
            set { __3_5_5 = value; }
        }

        private string __3_5_6;

        public string _3_5_6_
        {
            get { return __3_5_6; }
            set { __3_5_6 = value; }
        }

        private string __3_5_7;

        public string _3_5_7_
        {
            get { return __3_5_7; }
            set { __3_5_7 = value; }
        }


        private string __3_6;

        public string _3_6_
        {
            get { return __3_6; }
            set { __3_6 = value; }
        }

        private string __3_7;

        public string _3_7_
        {
            get { return __3_7; }
            set { __3_7 = value; }
        }

        private bool __3_8_Si;

        public bool _3_8_Si
        {
            get { return __3_8_Si; }
            set { __3_8_Si = value; }
        }

        private bool __3_8_No;

        public bool _3_8_No
        {
            get { return __3_8_No; }
            set { __3_8_No = value; }
        }

        private string __3_8_1;

        public string _3_8_1
        {
            get { return __3_8_1; }
            set { __3_8_1 = value; }
        }

        private bool __3_9_Si;

        public bool _3_9_Si
        {
            get { return __3_9_Si; }
            set { __3_9_Si = value; }
        }

        private bool __3_9_No;

        public bool _3_9_No
        {
            get { return __3_9_No; }
            set { __3_9_No = value; }
        }

        private string __3_9_1;

        public string _3_9_1_
        {
            get { return __3_9_1; }
            set { __3_9_1 = value; }
        }

        #endregion

        #region Seccion 4

        private bool __4_1_Si;

        public bool _4_1_Si
        {
            get { return __4_1_Si; }
            set { __4_1_Si = value; }
        }

        private bool __4_1_No;

        public bool _4_1_No
        {
            get { return __4_1_No; }
            set { __4_1_No = value; }
        }

        private bool __4_1_Algunas;

        public bool _4_1_Algunas
        {
            get { return __4_1_Algunas; }
            set { __4_1_Algunas = value; }
        }

        private int __4_2;

        public int _4_2_
        {
            get { return __4_2; }
            set { __4_2 = value; }
        }

        private bool __4_3_Si;

        public bool _4_3_Si
        {
            get { return __4_3_Si; }
            set { __4_3_Si = value; }
        }

        private bool __4_3_No;

        public bool _4_3_No
        {
            get { return __4_3_No; }
            set { __4_3_No = value; }
        }

        private string __4_3_1;

        public string _4_3_1_
        {
            get { return __4_3_1; }
            set { __4_3_1 = value; }
        }

        #endregion

        #region Seccion 5

        private bool __5_1_si;

        public bool _5_1_Si
        {
            get { return __5_1_si; }
            set { __5_1_si = value; }
        }

        private bool __5_1_no;

        public bool _5_1_No
        {
            get { return __5_1_no; }
            set { __5_1_no = value; }
        }

        private int __5_1_1;

        public int _5_1_1
        {
            get { return __5_1_1; }
            set { __5_1_1 = value; }
        }


        #endregion

        #region Observaciones

        private string _observaciones;

        public string Observaciones
        {
            get { return _observaciones; }
            set { _observaciones = value; }
        }

        #endregion

        #endregion

        /// <summary>
        /// Almacena la información de Lectura de Contexto para el Establecimiento Educativo.
        /// </summary>
        /// <param name="idee">Identificador del Establecimiento Educativo</param>
        /// <param name="idmedicion">Identificador de la medición a la que corresponde</param>
        /// <returns>Valor que representa el estado de la transacción</returns>
        public bool Almacenar(int idee, int idmedicion)
        {
            try
            {
                _cn.Conectar();

                var valores = new ArrayList();

                //Model.LecturaContextoEE objLecturaContextoEE = new Model.LecturaContextoEE
                //{
                //valores.Add(idee.ToString());
                //valores.Add(idmedicion.ToString());
                valores.Add(_num_sedes);

                #region Seccion 1

                valores.Add(this._f11.ToString());
                valores.Add(this._f12.ToString());
                valores.Add(this._f13.ToString());
                valores.Add(this._f14.ToString());
                valores.Add(this._f15.ToString());
                valores.Add(this._d.ToString());
                valores.Add(this.__1_2_rural.ToString());
                valores.Add(this.__1_2_urbana.ToString());

                valores.Add(__c_1.ToString());
                valores.Add(__c_2.ToString());
                valores.Add(__c_3.ToString());
                valores.Add(__c_4.ToString());
                valores.Add(__c_5.ToString());

                #endregion

                #region Seccion 2

                valores.Add(this.__2_1.ToString());
                valores.Add(this.__2_2_e1.ToString());
                valores.Add(this.__2_2_e2.ToString());
                valores.Add(this.__2_2_e3.ToString());
                valores.Add(this.__2_2_e4.ToString());
                valores.Add(this.__2_2_e5.ToString());
                valores.Add(this.__2_2_e6.ToString());
                valores.Add(this.__2_3_s1.ToString());
                valores.Add(this.__2_3_s2.ToString());
                valores.Add(this.__2_3_s3.ToString());
                valores.Add(this.__2_3_s4.ToString());
                valores.Add(this.__2_3_sNosabe.ToString());
                valores.Add(this.__2_3_sNoTiene.ToString());
                valores.Add(this.___2_4_Si.ToString());
                valores.Add(this.___2_4_No.ToString());
                valores.Add(this.__2_5_1.ToString());
                valores.Add(this.__2_5_2.ToString());
                valores.Add(this.__2_5_3_.ToString());

                #endregion

                #region Seccion 3

                valores.Add(this.__3_1.ToString());
                valores.Add(this.__3_2_.ToString());
                valores.Add(this.__3_3_.ToString());
                valores.Add(this.__3_4_Si.ToString());
                valores.Add(this.__3_4_No.ToString());
                valores.Add(this.__3_4_1.ToString());
                valores.Add(this.__3_5_Si.ToString());
                valores.Add(this.__3_5_No.ToString());
                valores.Add(this.__3_5_1.ToString());
                valores.Add(this.__3_5_2.ToString());
                valores.Add(this.__3_5_3.ToString());
                valores.Add(this.__3_5_4.ToString());
                valores.Add(this.__3_5_5.ToString());
                valores.Add(this.__3_5_6.ToString());
                valores.Add(this.__3_5_7.ToString());
                valores.Add(this.__3_6.ToString());
                valores.Add(this.__3_7.ToString());
                valores.Add(this.__3_8_Si.ToString());
                valores.Add(this.__3_8_No.ToString());
                valores.Add(this.__3_8_1.ToString());
                valores.Add(this.__3_9_Si.ToString());
                valores.Add(this.__3_9_No.ToString());

                #endregion

                #region Seccion 4

                valores.Add(this.__4_1_Si.ToString());
                valores.Add(this.__4_1_No.ToString());
                valores.Add(this.__4_1_Algunas.ToString());
                valores.Add(this.__4_2.ToString());
                valores.Add(this._4_3_Si.ToString());
                valores.Add(this._4_3_No.ToString());
                valores.Add(this.__4_3_1.ToString());

                #endregion

                #region Seccion 5

                valores.Add(this.__5_1_si.ToString());
                valores.Add(this.__5_1_no.ToString());
                valores.Add(this.__5_1_1.ToString());

                #endregion

                #region Seccion Observaciones

                valores.Add(_observaciones.ToString());

                #endregion

                //};

                string insert = "INSERT INTO dbo_LecturaContextoEE (IdIE, IdMedicion, NumeroSedes, f11 ,  f12 ,  f13 ,  f14 ,  f15 ,  C_1 ,  C_2 ,  C_3 ,  C_4 ,  C_5 ,  d ,  _1_2bUrbana ,  _1_2bRural ,  _2_1 ,  _2_2_E1 ,  _2_2_E2 ,  _2_2_E3 ,  _2_2_E4 ,  _2_2_E5 ,  _2_2_E6 ,  _2_3_S1 ,  _2_3_S2 ,  _2_3_S3 ,  _2_3_S4 ,  _2_3_NoSabe ,  _2_3_NoTiene ,  _2_4_Si ,  _2_4_No ,  _2_5_1 ,  _2_5_2 ,  _2_5_3 ,  _3_1 ,  _3_2 ,  _3_3 ,  _3_4_Si ,  _3_4_No ,  _3_4_1 ,  _3_5_Si ,  _3_5_No ,  _3_5_1 ,  _3_5_2 ,  _3_5_3 ,  _3_5_4 ,  _3_5_5 ,  _3_5_6 ,  _3_5_7 ,  _3_6 ,  _3_7 ,  _3_8_Si ,  _3_8_No ,  _3_8_1 ,  _3_9_Si ,  _3_9_No ,  _3_9_1 ,  _4_1_Si ,  _4_1_No ,  _4_1_Algunas ,  _4_2 ,  _4_3_Si ,  _4_3_No ,  _4_3_1 ,  _5_1_Si ,  _5_1_No ,  _5_1_1 ,  Observaciones ) VALUES ({0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {12}, {13}, {14}, {15}, {16}, {17}, {18}, {19}, {20}, {21}, {22}, {23}, {24}, {25}, {26}, {27}, {28}, {29}, {30}, {31}, {32}, {33}, {34}, {35}, {36}, {37}, {38}, {39}, {40}, {41}, {42}, {43}, {44}, {45}, {46}, {47}, {48}, {49}, {50}, {51}, {52}, {53}, {54}, {55}, {56}, {57}, {58}, {59}, {60}, {61}, {62}, {63}, {64}, {65}, {66}, {67}, {68})";
                string query = String.Format(insert, valores.ToArray());
                System.Windows.Forms.Application.DoEvents();
                _cn.Ejecutar(query);
                _cn.Desconectar();
                //_db.LecturaContextoEEs.InsertOnSubmit(objLecturaContextoEE);
                //_db.SubmitChanges();

                return true;
            }
            catch (Exception) { _cn.Desconectar(); return false; }
        }

        public bool Actualizar(int idee, int idmedicion)
        {
            try
            {
                var ds_lsee = _db.dbo_LecturaContextoEE;
                var da_lcee = new ESMOffline.ESMDataSetTableAdapters.dbo_LecturaContextoEETableAdapter();

                da_lcee.Fill(ds_lsee);

                var lcee = (from lc in ds_lsee
                            where lc.IdIE == idee && lc.IdMedicion == idmedicion
                            select lc).Single();

                //lcee.Medicione.FechaMedicion = DateTime.Now.AddHours(2);

                var valores = new ArrayList();

                valores.Add(_num_sedes);

                #region Seccion 1

                valores.Add(this._f11.ToString());
                valores.Add(this._f12.ToString());
                valores.Add(this._f13.ToString());
                valores.Add(this._f14.ToString());
                valores.Add(this._f15.ToString());
                valores.Add(this.__1_2_rural.ToString());
                valores.Add(this.__1_2_urbana.ToString());

                valores.Add(__c_1.ToString());
                valores.Add(__c_2.ToString());
                valores.Add(__c_3.ToString());
                valores.Add(__c_4.ToString());
                valores.Add(__c_5.ToString()); //12

                #endregion

                #region Seccion 2

                valores.Add(this.__2_1.ToString());
                valores.Add(this.__2_2_e1.ToString());
                valores.Add(this.__2_2_e2.ToString());
                valores.Add(this.__2_2_e3.ToString());
                valores.Add(this.__2_2_e4.ToString());
                valores.Add(this.__2_2_e5.ToString());
                valores.Add(this.__2_2_e6.ToString());
                valores.Add(this.__2_3_s1.ToString());
                valores.Add(this.__2_3_s2.ToString());
                valores.Add(this.__2_3_s3.ToString());
                valores.Add(this.__2_3_s4.ToString());
                valores.Add(this.__2_3_sNosabe.ToString());
                valores.Add(this.__2_3_sNoTiene.ToString());
                valores.Add(this.___2_4_Si.ToString());
                valores.Add(this.___2_4_No.ToString());
                valores.Add(this.__2_5_1.ToString());
                valores.Add(this.__2_5_2.ToString());
                valores.Add(this.__2_5_3_.ToString());//30

                #endregion

                #region Seccion 3

                valores.Add(this.__3_1.ToString());
                valores.Add(this.__3_2_.ToString());
                valores.Add(this.__3_3_.ToString());
                valores.Add(this.__3_4_Si.ToString());
                valores.Add(this.__3_4_No.ToString());
                valores.Add(this.__3_4_1.ToString());
                valores.Add(this.__3_5_Si.ToString());
                valores.Add(this.__3_5_No.ToString());
                valores.Add(this.__3_5_1.ToString());
                valores.Add(this.__3_5_2.ToString());//40
                valores.Add(this.__3_5_3.ToString());
                valores.Add(this.__3_5_4.ToString());
                valores.Add(this.__3_5_5.ToString());
                valores.Add(this.__3_5_6.ToString());
                valores.Add(this.__3_5_7.ToString());//45
                valores.Add(this.__3_6.ToString());
                valores.Add(this.__3_7.ToString());
                valores.Add(this.__3_8_Si.ToString());
                valores.Add(this.__3_8_No.ToString());//49
                valores.Add(this.__3_8_1.ToString());
                valores.Add(this.__3_9_Si.ToString());
                valores.Add(this.__3_9_No.ToString());//52
                valores.Add(this.__3_9_1.ToString());//52
                #endregion

                #region Seccion 4

                valores.Add(this.__4_1_Si.ToString());//53
                valores.Add(this.__4_1_No.ToString());
                valores.Add(this.__4_1_Algunas.ToString());
                valores.Add(this.__4_2.ToString());
                valores.Add(this._4_3_Si.ToString());
                valores.Add(this._4_3_No.ToString());
                valores.Add(this.__4_3_1.ToString());//59

                #endregion

                #region Seccion 5

                valores.Add(this.__5_1_si.ToString());
                valores.Add(this.__5_1_no.ToString());
                valores.Add(this.__5_1_1.ToString());

                #endregion

                #region Seccion Observaciones

                valores.Add(_observaciones.ToString());

                #endregion


                //_db.SubmitChanges();

                _cn.Conectar();

                string update = "UPDATE dbo_LecturaContextoEE";
                update += " SET Update_ = 1,NumeroSedes={0}, dbo_LecturaContextoEE.f11 ={1}, dbo_LecturaContextoEE.f12 ={2},dbo_LecturaContextoEE.f13 ={3}, dbo_LecturaContextoEE.f14 ={4}, dbo_LecturaContextoEE.f15 ={5},dbo_LecturaContextoEE.[_1_2bUrbana] = {6}, dbo_LecturaContextoEE.[_1_2bRural] ={7}, dbo_LecturaContextoEE.C_1 ={8}, dbo_LecturaContextoEE.C_2 ={9}, dbo_LecturaContextoEE.C_3 ={10}, dbo_LecturaContextoEE.C_4 ={11}, dbo_LecturaContextoEE.C_5 ={12}, dbo_LecturaContextoEE.[_2_1] ={13}, dbo_LecturaContextoEE.[_2_2_E1] = {14}, dbo_LecturaContextoEE.[_2_2_E2] ={15}, dbo_LecturaContextoEE.[_2_2_E3] = {16}, dbo_LecturaContextoEE.[_2_2_E4] = {17},";
                update += " dbo_LecturaContextoEE.[_2_2_E5] = {18}, dbo_LecturaContextoEE.[_2_2_E6] ={19}, dbo_LecturaContextoEE.[_2_3_S1] = {20}, dbo_LecturaContextoEE.[_2_3_S2] = {21}, dbo_LecturaContextoEE.[_2_3_S3] = {22}, dbo_LecturaContextoEE.[_2_3_S4] ={23}, dbo_LecturaContextoEE.[_2_3_NoSabe] = {24}, dbo_LecturaContextoEE.[_2_3_NoTiene] ={25}, dbo_LecturaContextoEE.[_2_4_Si] ={26}, dbo_LecturaContextoEE.[_2_4_No] ={27}, dbo_LecturaContextoEE.[_2_5_1] = {28}, dbo_LecturaContextoEE.[_2_5_2] ={29}, ";
                update += " dbo_LecturaContextoEE.[_2_5_3] ={30}, dbo_LecturaContextoEE.[_3_1] = '{31}', dbo_LecturaContextoEE.[_3_2] = '{32}', dbo_LecturaContextoEE.[_3_3] = '{33}', dbo_LecturaContextoEE.[_3_4_Si] = {34}, dbo_LecturaContextoEE.[_3_4_No] = {35}, dbo_LecturaContextoEE.[_3_4_1] = '{36}', dbo_LecturaContextoEE.[_3_5_Si] = {37}, dbo_LecturaContextoEE.[_3_5_No] = {38}, dbo_LecturaContextoEE.[_3_5_1] = '{39}', dbo_LecturaContextoEE.[_3_5_2] ='{40}', dbo_LecturaContextoEE.[_3_5_3] ='{41}', dbo_LecturaContextoEE.[_3_5_4] ='{42}', dbo_LecturaContextoEE.[_3_5_5] = '{43}', ";
                update += " dbo_LecturaContextoEE.[_3_5_6] ='{44}', dbo_LecturaContextoEE.[_3_5_7] ='{45}', dbo_LecturaContextoEE.[_3_6] ='{46}', dbo_LecturaContextoEE.[_3_7] = '{47}', dbo_LecturaContextoEE.[_3_8_Si] ={48}, dbo_LecturaContextoEE.[_3_8_No] = {49}, dbo_LecturaContextoEE.[_3_8_1] ='{50}', dbo_LecturaContextoEE.[_3_9_Si] ={51}, dbo_LecturaContextoEE.[_3_9_No] ={52}, dbo_LecturaContextoEE.[_3_9_1] = '{53}', dbo_LecturaContextoEE.[_4_1_Si] ={54}, dbo_LecturaContextoEE.[_4_1_No] ={55}, dbo_LecturaContextoEE.[_4_1_Algunas] ={56}, ";
                update += " dbo_LecturaContextoEE.[_4_2] ={57}, dbo_LecturaContextoEE.[_4_3_Si] = {58}, dbo_LecturaContextoEE.[_4_3_No] = {59}, dbo_LecturaContextoEE.[_4_3_1] = '{60}', dbo_LecturaContextoEE.[_5_1_Si] = {61}, dbo_LecturaContextoEE.[_5_1_No] = {62}, dbo_LecturaContextoEE.[_5_1_1] ={63}, dbo_LecturaContextoEE.Observaciones ='{64}' WHERE dbo_LecturaContextoEE.IdIE = {65}";

                valores.Add(idee);

                string query = String.Format(update, valores[0], valores[1], valores[2], valores[3], valores[4], valores[5], valores[6], valores[7], valores[8], valores[9], valores[10], valores[11], valores[12], valores[13], valores[14], valores[15], valores[16], valores[17], valores[18], valores[19], valores[20], valores[21], valores[22], valores[23], valores[24], valores[25], valores[26], valores[27], valores[28], valores[29], valores[30], valores[31], valores[32], valores[33], valores[34], valores[35], valores[36], valores[37], valores[38], valores[39], valores[40], valores[41], valores[42], valores[43], valores[44], valores[45], valores[46], valores[47], valores[48], valores[49], valores[50], valores[51], valores[52], valores[53], valores[54], valores[55], valores[56], valores[57], valores[58], valores[59], valores[60], valores[61], valores[62], valores[63], valores[64], valores[65]);
                _cn.Ejecutar(query);
                _cn.Desconectar();
                return true;
            }
            catch (Exception) { _cn.Desconectar(); return false; }

        }


        public ESMOffline.ESMDataSet.dbo_LecturaContextoEERow ObtenerLCEE(int idmedicion)
        {
            try
            {
                var ds_lsee = _db.dbo_LecturaContextoEE;
                var da_lcee = new ESMOffline.ESMDataSetTableAdapters.dbo_LecturaContextoEETableAdapter();

                da_lcee.Fill(ds_lsee);

                var lcee = (from l in ds_lsee
                            where l.IdMedicion == idmedicion
                            select l).Single();

                return lcee;
            }
            catch (Exception) { return null; }
        }
    }
}